package com.tuijian.vo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 *
 * @author 贾清博
 * {@code @date} 2023-02-13
 * @version 1.0
 * {@code @description} 数据类
 *
 */
@Data
@NoArgsConstructor
public class TrackingData implements Serializable {
    /**
     * 用户id
     */
    private String userId;
    /**
     * appid
     */
    private List<String> itemId;
    /**
     * app版本
     */
    private String type;
    /**
     * 事件名称
     */
    private String isRecommend;
    /**
     * 事件类型
     */
    private String eventType;
    /**
     * 触发时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")

    private Date triggerTime;


    public TrackingData(String userId, List<String> itemId, String type, String isRecommend, String eventType, Date triggerTime) {
        this.userId = userId;
        this.itemId = itemId;
        this.type = type;
        this.isRecommend = isRecommend;
        this.eventType = eventType;
        this.triggerTime = triggerTime;
    }

    @Override
    public String toString() {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return userId+","+
                JSON.toJSONString(itemId)+","+
                type+","+
                isRecommend +","+
                eventType+","+
                sdf.format(triggerTime);
    }
}
